import 'App.css'
import { Router, Route, Redirect, Switch } from 'react-router-dom'

import AuthRoute from 'components/AuthRoute'
import history from 'utilis/history'
import React, { Suspense } from 'react'
const Layout = React.lazy(() => import('pages/Layout'))
const Login = React.lazy(() => import('pages/Login'))

function App() {
  return (
    <Router history={history}>
      <div className='App'>
        <Suspense fallback={<div>Loading...</div>}>
          <Switch>
            <Redirect
              exact
              from='/'
              to='/home'
            ></Redirect>
            <Route
              path='/login'
              component={Login}
            ></Route>
            <AuthRoute
              path='/home'
              component={Layout}
            ></AuthRoute>
          </Switch>
        </Suspense>
      </div>
    </Router>
  )
}

export default App
